/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ConditionSignals.java
 *
 * Created on 18.12.2011., 16.27.57
 */
package aor2.gui.cpu.signals;

import aor2.cpu.blockcontrol.ConditionSignalSet;
import java.awt.Graphics;
import java.awt.Graphics2D;

/**
 * 
 * @author Moxi
 */
public class ConditionSignals extends javax.swing.JPanel {

	private ConditionSignalSet condSet;

	/** Creates new form ConditionSignals */
	public ConditionSignals() {
		condSet = ConditionSignalSet.getInstance();
		initComponents();
		refreshTable();
	}

	public void refreshTable() {
		int cnt = table.getRowCount();
		for (int i = 0; i < cnt; i++) {
			String signalName = table.getValueAt(i, 0).toString();
			table.setValueAt(
					Boolean.toString(condSet.get(signalName).isActive()), i, 1);
		}
	}

	@Override
	protected void paintComponent(Graphics g) {
		refreshTable();
		super.paintComponent(g);
	}

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
	// <editor-fold defaultstate="collapsed"
	// desc="Generated Code">//GEN-BEGIN:initComponents
	private void initComponents() {

		jLabel1 = new javax.swing.JLabel();
		jScrollPane1 = new javax.swing.JScrollPane();
		table = new javax.swing.JTable();

		jLabel1.setFont(new java.awt.Font("Segoe UI", 1, 12)); // NOI18N
		jLabel1.setText("Uslovni Signali");

		table.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {
				{ "adr0", null }, { "adr1", null }, { "notpom1", null },
				{ "notpom2", null }, { "regdir1", null }, { "postinc1", null },
				{ "predec1", null }, { "index1", null }, { "regind1", null },
				{ "predecind1", null }, { "postincind1", null },
				{ "indexind1", null }, { "regdir2", null },
				{ "postinc2", null }, { "predec2", null }, { "index2", null },
				{ "regind2", null }, { "predecind2", null },
				{ "postincind2", null }, { "indexind2", null },
				{ "immed2", null }, { "eql", null }, { "PRINS", null },
				{ "PRCOD", null }, { "PRADR", null }, { "PRINM", null },
				{ "PRIMM", null }, { "MOV", null }, { "SUB", null },
				{ "OR", null }, { "INC", null }, { "DEC", null },
				{ "NOT", null }, { "ASR", null }, { "JMPIND", null },
				{ "JSRIND", null }, { "BRN", null }, { "BSR", null },
				{ "BNZ", null }, { "INT", null }, { "RTI", null },
				{ "RTS", null }, { "INTE", null }, { "INTD", null },
				{ "TRPE", null }, { "TRPD", null }, { "run", null },
				{ "notPrekid", null } }, new String[] { "Signal", "Vrednost" }) {
			Class[] types = new Class[] { java.lang.String.class,
					java.lang.String.class };
			boolean[] canEdit = new boolean[] { false, false };

			public Class getColumnClass(int columnIndex) {
				return types[columnIndex];
			}

			public boolean isCellEditable(int rowIndex, int columnIndex) {
				return canEdit[columnIndex];
			}
		});
		jScrollPane1.setViewportView(table);

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
		this.setLayout(layout);
		layout.setHorizontalGroup(layout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(
						layout.createSequentialGroup()
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.LEADING)
												.addGroup(
														layout.createSequentialGroup()
																.addGap(98, 98,
																		98)
																.addComponent(
																		jLabel1))
												.addGroup(
														layout.createSequentialGroup()
																.addContainerGap()
																.addComponent(
																		jScrollPane1,
																		javax.swing.GroupLayout.PREFERRED_SIZE,
																		255,
																		javax.swing.GroupLayout.PREFERRED_SIZE)))
								.addContainerGap(15, Short.MAX_VALUE)));
		layout.setVerticalGroup(layout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(
						layout.createSequentialGroup()
								.addContainerGap()
								.addComponent(jLabel1)
								.addPreferredGap(
										javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
								.addComponent(jScrollPane1,
										javax.swing.GroupLayout.DEFAULT_SIZE,
										318, Short.MAX_VALUE).addContainerGap()));
	}// </editor-fold>//GEN-END:initComponents
		// Variables declaration - do not modify//GEN-BEGIN:variables

	private javax.swing.JLabel jLabel1;
	private javax.swing.JScrollPane jScrollPane1;
	private javax.swing.JTable table;
	// End of variables declaration//GEN-END:variables
}
